package holdobject;

import practice.Rand;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;

public class QueueDemo {
    public static void printQ(Queue queue){
        while (queue.peek()!=null){
            System.out.print(queue.remove()+" ");

        }System.out.println();
    }

    public static void main(String[] args) {
        Queue<Integer> queue=new LinkedList<Integer>();
        Random random =new Random(47);
        for (int i = 0; i <10 ; i++) {
            //如果在不违反容量限制的情况下立即执行，则将指定的元素插入到此队列中。
            queue.offer(random.nextInt(i+10));
            printQ(queue);
        }
        System.out.println();
        Queue<Character> qc=new LinkedList<Character>();
        for (char c:"Brother".toCharArray()){//字符串变字符数组
            qc.offer(c);//再插入到qc队列里面
            System.out.print(qc.remove()+" ");
        }
    }
}
